import express from 'express';
import cookieParser from 'cookie-parser';
import sessionParser from 'cookie-parser';
import consolidate from 'consolidate';
import bodyParser from 'body-parser';
import logger from 'morgan';
import uuid from 'uuid';

const app = express();
app.listen(8080);
app.use(express.static("./public"));
app.use(bodyParser.urlencoded({extended:true,limit:"500mb"}));
app.use(bodyParser.json());
app.use(bodyParser.text());//这两种是什么用处
app.use(cookieParser("ty.cn"));
app.use(sessionParser({
    name:"my_session",
    genid:function () {
        return uuid.v1();
    },
    secret:"ty.cn"
}))
app.use(logger("dev"));
let writeStream = require("fs").createWriteStream("./logs/logs.log",{flags:"a"});
app.use(logger("combined",{
    "stream":writeStream
}));

app.set("view engine","html");
app.set("views","./views");
app.engine("html",consolidate.ejs);

app.use("/admin", require("./route/admin/adminRouter"));